//
//  YSRequest+Utiltes.m
//  GuBoShi
//
//  Created by 袁斌 on 2017/4/6.
//  Copyright © 2017年 YiShi. All rights reserved.
//

#import "YSRequest+Utiltes.h"

@implementation YSRequest (Utiltes)

- (NSString *)cacheKeyWithParam:(NSDictionary *)param urlString:(NSString *)urlString
{
    if(!param) { return urlString; }
    
    // 将参数字典转换成字符串
    NSData *stringData = [NSJSONSerialization dataWithJSONObject:param options:0 error:nil];
    NSString *paraString = [[NSString alloc] initWithData:stringData encoding:NSUTF8StringEncoding];
    
    // 将URL与转换好的参数字符串拼接在一起,成为最终存储的KEY值
    NSString *cacheKey = [NSString stringWithFormat:@"%@%@",urlString,paraString];
    
    return cacheKey;
}

@end
